from math import sqrt, acos, atan
from matplotlib.patches import Circle
import matplotlib.pyplot as plt


def distance(p1, p2):
    return sqrt(pow(p1[0]-p2[0], 2) + pow(p1[1]-p2[1], 2))


def get_angle_cos(p1, p2, p3):
    a = distance(p1, p3)
    b = distance(p1, p2)
    c = distance(p2, p3)
    cos_alpha = (pow(b, 2) + pow(c, 2) - pow(a, 2)) / (2 * b * c)
    alpha = acos(cos_alpha)
    return alpha


def get_angle_tan(p1, p2):
    return atan(_k(p1, p2))


def _k(p1, p2):
    return (p1[1] - p2[1]) / (p1[0] - p2[0])


def draw_circle(x, y, R):
    print('(x - {})^2 + (y - {})^2 = {}'.format(x, y, R * R))
    cir = Circle(xy=(x, y), radius=R, alpha=0.5)
    fig, ax = plt.subplots()
    ax.set_xbound(x - R - 500, x + R + 500)
    ax.set_ybound(y - R - 500, y + R + 500)
    ax.add_patch(cir)
    plt.axis('equal')
    plt.show()
